<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-7-20
 * Time: 下午2:16
 */

namespace ActionsHttp;

use Data\Order_form_DAO;
use Data\Order_for_foods_DAO;
use Data\Food_DAO;

class ConsumerOrderFinishedList extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        // 商铺id
        $restaurant_id = (int)$this->data[RESTAURANT_ID];
        // 顾客id
        $consumer_id = $_SESSION[CONSUMER_ID];
        $consumer_id = 1;
        // 商铺id
        $restaurant_id = (int)$this->data[RESTAURANT_ID];

        // 每页显示条数
        $every_page_counts = (int)$this->data[EVERY_PAGE_COUNTS];
        // 页码
        $page_index = (int)$this->data[PAGE_INDEX];
        // 起始值
        $list_start = ($page_index-1)*$every_page_counts;

        // 已完成订单列表
        $order_form_list_finished = Order_form_DAO::getListByConsumerId($consumer_id,$list_start,$every_page_counts,$restaurant_id);

        foreach ($order_form_list_finished as $order_form_list_finished_record) {
            $order_form_id = $order_form_list_finished_record->getORDER_FORM_ID();
            // 订单中商品信息
            $order_for_food_list = Order_for_foods_DAO::getListByOrderFormId($order_form_id);
            // 订单信息
            $order_form_info = $order_form_list_finished_record->getArray();
            $order_form_info[ORDER_FOR_FOOD_INFO] = $order_for_food_list;
            // 订单全部信息
            $order_info[] = $order_form_info;
        }

        // 返回数据
        $this->setValue(ORDER_FORM_FINISHED_LIST,$order_info);
        $this->ResponseDataToCurrentClient();
    }
}